Leaflet Graph of the State Centers (Plus all the other data)
state_x77_df <- as.data.frame(state.x77)
leaflet()%>%
addTiles()%>%
setView(lng = -100, lat = 40, zoom = 4) %>%
addCircleMarkers(
lng = state.center$x,
lat = state.center$y,
popup = paste(
state.name,"<br>",
"Approximate Area in Square Miles:",state.area,"<br>",
"State Region:",state.region,"<br>",
"State Division:",state.division,"<br>",
"State Population as of July 1st, 1975:",state_x77_df$Population,"<br>",
"Income per Captia in 1974:",state_x77_df$Income,"<br>",
"State Illiteracy Rate in 1970:",state_x77_df$Illiteracy,"%","<br>",
"Life Expectancy from 1969-1971:",state_x77_df$`Life Exp`,"Years old","<br>",
"High School Graduation Rate in 1970:",state_x77_df$`HS Grad`,"%","<br>",
"Likelyhood of getting murdered in 1976:",as.numeric(state_x77_df$Murder)/1000,"%","<br>",
"Mean number of days spnt below freezing from 1931-1960:",state_x77_df$Frost,"Days"
)
)
Model Building
Murder
hs_grad_murder_model <- lm(Murder ~ `HS Grad`, data = state_x77_df)
summary(hs_grad_murder_model)
##
## Call:
## lm(formula = Murder ~ `HS Grad`, data = state_x77_df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.6043 -2.2168 0.0033 2.2734 6.9533
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 19.22236 3.09249 6.216 1.17e-07 ***
## `HS Grad` -0.22302 0.05758 -3.873 0.000325 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.256 on 48 degrees of freedom
## Multiple R-squared: 0.2381, Adjusted R-squared: 0.2222
## F-statistic: 15 on 1 and 48 DF, p-value: 0.0003248
slopeHSG_M <--0.22302
interceptHSG_M <-19.22236
pHSG_M <-.0003248
r2HSG_M <-.2381
ar2HSG_M <-.2222
illiteracy_murder_model <- lm(Murder ~ Illiteracy, data = state_x77_df)
summary(illiteracy_murder_model)
##
## Call:
## lm(formula = Murder ~ Illiteracy, data = state_x77_df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -5.5315 -2.0602 -0.2503 1.6916 6.9745
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.3968 0.8184 2.928 0.0052 **
## Illiteracy 4.2575 0.6217 6.848 1.26e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.653 on 48 degrees of freedom
## Multiple R-squared: 0.4942, Adjusted R-squared: 0.4836
## F-statistic: 46.89 on 1 and 48 DF, p-value: 1.258e-08
slopeI_M <-4.2575
interceptI_M <-2.3968
pI_M <-1.258e-08
r2I_M <-.4942
ar2I_M <-.4836
life_exp_murder_model <- lm(Murder ~ `Life Exp`, data = state_x77_df)
summary(life_exp_murder_model)
##
## Call:
## lm(formula = Murder ~ `Life Exp`, data = state_x77_df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -5.7272 -1.6733 -0.1734 1.4909 4.8680
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 159.576 17.579 9.078 5.45e-12 ***
## `Life Exp` -2.147 0.248 -8.660 2.26e-11 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.33 on 48 degrees of freedom
## Multiple R-squared: 0.6097, Adjusted R-squared: 0.6016
## F-statistic: 74.99 on 1 and 48 DF, p-value: 2.26e-11
slopeLE_M <--2.147
interceptLE_M <-159.576
pLE_M <-2.26e-11
r2LE_M <-.6097
ar2LE_M <-.6016
income_murder_model <- lm(Murder ~ Income, data = state_x77_df)
summary(income_murder_model)
##
## Call:
## lm(formula = Murder ~ Income, data = state_x77_df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.0495 -2.8033 -0.2727 3.0730 6.5999
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 13.5093092 3.7782753 3.576 0.00081 ***
## Income -0.0013822 0.0008439 -1.638 0.10797
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.63 on 48 degrees of freedom
## Multiple R-squared: 0.05294, Adjusted R-squared: 0.03321
## F-statistic: 2.683 on 1 and 48 DF, p-value: 0.108
slopeIn_M <--0.0013822
interceptIn_M <-13.5093092
pIn_M <-0.108
r2In_M <-.05294
ar2In_M <-.03321
frost_murder_model <- lm(Murder ~ Frost, data = state_x77_df)
summary(frost_murder_model)
##
## Call:
## lm(formula = Murder ~ Frost, data = state_x77_df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -5.8510 -2.6336 -0.2825 2.2983 7.3191
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 11.375689 1.005494 11.314 3.83e-15 ***
## Frost -0.038270 0.008635 -4.432 5.40e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.142 on 48 degrees of freedom
## Multiple R-squared: 0.2904, Adjusted R-squared: 0.2756
## F-statistic: 19.64 on 1 and 48 DF, p-value: 5.405e-05
slopeF_M <--0.038270
interceptF_M <-11.375689
pF_M <-5.405e-05
r2F_M <-.2904
ar2F_M <-.2756
pMurder <- c(pHSG_M, pI_M, pLE_M, pIn_M, pF_M)
r2Murder <- c(r2HSG_M, r2I_M, r2LE_M, r2In_M, r2F_M)
ar2Murder <- c(ar2HSG_M, ar2I_M, ar2LE_M, ar2In_M, ar2F_M)
slopeMurder <- c(slopeHSG_M, slopeI_M, slopeLE_M, slopeIn_M, slopeF_M)
interceptMurder <- c(interceptHSG_M, interceptI_M, interceptLE_M, interceptIn_M, interceptF_M)
murder_stats <- cbind(slopeMurder, interceptMurder, pMurder, r2Murder, ar2Murder)
colnames(murder_stats) <- c("Slope","Intercept", "P-Value", "R Squared Value", "Adjusted R Squared Value")
rownames(murder_stats) <- c("HS Grad", "Illiteracy", "Life Exp", "Income", "Frost")
murder_stats
## Slope Intercept P-Value R Squared Value
## HS Grad -0.2230200 19.22236 3.248e-04 0.23810
## Illiteracy 4.2575000 2.39680 1.258e-08 0.49420
## Life Exp -2.1470000 159.57600 2.260e-11 0.60970
## Income -0.0013822 13.50931 1.080e-01 0.05294
## Frost -0.0382700 11.37569 5.405e-05 0.29040
## Adjusted R Squared Value
## HS Grad 0.22220
## Illiteracy 0.48360
## Life Exp 0.60160
## Income 0.03321
## Frost 0.27560
Illiteracy
hs_grad_illiteracy_model <- lm(Illiteracy ~ `HS Grad`, data = state_x77_df)
summary(hs_grad_illiteracy_model)
##
## Call:
## lm(formula = Illiteracy ~ `HS Grad`, data = state_x77_df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.6605 -0.3064 -0.1225 0.1815 1.1660
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.80389 0.44093 8.627 2.53e-11 ***
## `HS Grad` -0.04960 0.00821 -6.041 2.17e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.4642 on 48 degrees of freedom
## Multiple R-squared: 0.4319, Adjusted R-squared: 0.4201
## F-statistic: 36.49 on 1 and 48 DF, p-value: 2.172e-07
slopeHSG_I <--0.04960
interceptHSG_I <-3.80389
pHSG_I <-2.172e-07
r2HSG_I <-0.4319
ar2HSG_I <-0.4201
life_exp_illiteracy_model <- lm(Illiteracy ~ `Life Exp`, data = state_x77_df)
summary(life_exp_illiteracy_model)
##
## Call:
## lm(formula = Illiteracy ~ `Life Exp`, data = state_x77_df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.16396 -0.34803 -0.04918 0.21774 1.45718
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 20.10925 3.75643 5.353 2.40e-06 ***
## `Life Exp` -0.26721 0.05299 -5.043 6.97e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.4979 on 48 degrees of freedom
## Multiple R-squared: 0.3463, Adjusted R-squared: 0.3327
## F-statistic: 25.43 on 1 and 48 DF, p-value: 6.969e-06
slopeLE_I <--0.26721
interceptLE_I <-20.10925
pLE_I <-6.969e-06
r2LE_I <-0.3463
ar2LE_I <-0.3327
income_illiteracy_model <- lm(Illiteracy ~ Income, data = state_x77_df)
summary(income_illiteracy_model)
##
## Call:
## lm(formula = Illiteracy ~ Income, data = state_x77_df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.79927 -0.46481 -0.09793 0.34011 1.24378
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.0932014 0.5765787 5.365 2.3e-06 ***
## Income -0.0004336 0.0001288 -3.367 0.00151 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5539 on 48 degrees of freedom
## Multiple R-squared: 0.191, Adjusted R-squared: 0.1742
## F-statistic: 11.34 on 1 and 48 DF, p-value: 0.001505
slopeIn_I <--0.0004336
interceptIn_I <-3.0932014
pIn_I <-0.001505
r2In_I <-0.191
ar2In_I <-0.1742
frost_illiteracy_model <- lm(Illiteracy ~ Frost, data = state_x77_df)
summary(frost_illiteracy_model)
##
## Call:
## lm(formula = Illiteracy ~ Frost, data = state_x77_df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.14094 -0.27287 -0.04965 0.26300 1.15244
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.993074 0.145963 13.655 < 2e-16 ***
## Frost -0.007879 0.001253 -6.286 9.16e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.4561 on 48 degrees of freedom
## Multiple R-squared: 0.4515, Adjusted R-squared: 0.4401
## F-statistic: 39.51 on 1 and 48 DF, p-value: 9.156e-08
slopeF_I <--0.007879
interceptF_I <-1.993074
pF_I <-9.156e-08
r2F_I <-0.4515
ar2F_I <-0.4401
pIlliteracy <- c(pHSG_I, pLE_I, pIn_I, pF_I)
r2Illiteracy <- c(r2HSG_I, r2LE_I, r2In_I, r2F_I)
ar2Illiteracy <- c(ar2HSG_I, ar2LE_I, ar2In_I, ar2F_I)
slopeIlliteracy <- c(slopeHSG_I, slopeLE_I, slopeIn_I, slopeF_I)
interceptIlliteracy <- c(interceptHSG_I, interceptLE_I, interceptIn_I, interceptF_I)
illiteracy_stats <- cbind(slopeIlliteracy, interceptIlliteracy, pIlliteracy, r2Illiteracy, ar2Illiteracy)
colnames(illiteracy_stats) <- c("Slope","Intercept", "P-Value", "R Squared Value", "Adjusted R Squared Value")
rownames(illiteracy_stats) <- c("HS Grad", "Life Exp", "Income", "Frost")
illiteracy_stats
## Slope Intercept P-Value R Squared Value
## HS Grad -0.0496000 3.803890 2.172e-07 0.4319
## Life Exp -0.2672100 20.109250 6.969e-06 0.3463
## Income -0.0004336 3.093201 1.505e-03 0.1910
## Frost -0.0078790 1.993074 9.156e-08 0.4515
## Adjusted R Squared Value
## HS Grad 0.4201
## Life Exp 0.3327
## Income 0.1742
## Frost 0.4401
HS Grad
life_exp_hs_grad_model <- lm(`HS Grad` ~ `Life Exp`, data = state_x77_df)
summary(life_exp_hs_grad_model)
##
## Call:
## lm(formula = `HS Grad` ~ `Life Exp`, data = state_x77_df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -12.4422 -3.9243 0.0818 3.1755 19.0870
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -195.1879 50.0553 -3.899 0.000299 ***
## `Life Exp` 3.5031 0.7061 4.961 9.2e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 6.635 on 48 degrees of freedom
## Multiple R-squared: 0.339, Adjusted R-squared: 0.3252
## F-statistic: 24.61 on 1 and 48 DF, p-value: 9.196e-06
slopeLE_HS <-3.5031
interceptLE_HS <--195.1879
pLE_HS <-9.196e-06
r2LE_HS <-0.339
ar2LE_HS <-0.3252
income_hs_grad_model <- lm(`HS Grad` ~ Income, data = state_x77_df)
summary(income_hs_grad_model)
##
## Call:
## lm(formula = `HS Grad` ~ Income, data = state_x77_df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -10.038 -4.774 -1.067 5.022 17.564
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 16.961557 6.665384 2.545 0.0142 *
## Income 0.008149 0.001489 5.474 1.58e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 6.403 on 48 degrees of freedom
## Multiple R-squared: 0.3843, Adjusted R-squared: 0.3715
## F-statistic: 29.96 on 1 and 48 DF, p-value: 1.579e-06
slopeIn_HS <-0.008149
interceptIn_HS <-16.961557
pIn_HS <-1.579e-06
r2In_HS <-0.3843
ar2In_HS <-0.3715
frost_hs_grad_model <- lm(`HS Grad` ~ Frost, data = state_x77_df)
summary(frost_hs_grad_model)
##
## Call:
## lm(formula = `HS Grad` ~ Frost, data = state_x77_df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -14.0689 -4.4320 -0.4194 5.0779 14.7454
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 47.15464 2.42963 19.408 < 2e-16 ***
## Frost 0.05699 0.02086 2.731 0.00879 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.592 on 48 degrees of freedom
## Multiple R-squared: 0.1345, Adjusted R-squared: 0.1165
## F-statistic: 7.461 on 1 and 48 DF, p-value: 0.008795
slopeF_HS <-0.05699
interceptF_HS <-47.15464
pF_HS <-0.008795
r2F_HS <-0.1345
ar2F_HS <-0.1165
pHS <- c(pLE_HS, pIn_HS, pF_HS)
r2HS <- c(r2LE_HS, r2In_HS, r2F_HS)
ar2HS <- c(ar2LE_HS, ar2In_HS, ar2F_HS)
slopeHS <- c(slopeLE_HS, slopeIn_HS, slopeF_HS)
interceptHS <- c(interceptLE_HS, interceptIn_HS, interceptF_HS)
hs_grad_stats <- cbind(slopeHS, interceptHS, pHS, r2HS, ar2HS)
colnames(hs_grad_stats) <- c("Slope","Intercept", "P-Value", "R Squared Value", "Adjusted R Squared Value")
rownames(hs_grad_stats) <- c("Life Exp", "Income", "Frost")
hs_grad_stats
## Slope Intercept P-Value R Squared Value
## Life Exp 3.503100 -195.18790 9.196e-06 0.3390
## Income 0.008149 16.96156 1.579e-06 0.3843
## Frost 0.056990 47.15464 8.795e-03 0.1345
## Adjusted R Squared Value
## Life Exp 0.3252
## Income 0.3715
## Frost 0.1165
Income
life_exp_income_model <- lm(Income ~ `Life Exp`, data = state_x77_df)
summary(life_exp_income_model)
##
## Call:
## lm(formula = Income ~ `Life Exp`, data = state_x77_df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1023.75 -467.39 -34.34 339.73 2123.51
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -6603.48 4404.26 -1.499 0.1403
## `Life Exp` 155.75 62.13 2.507 0.0156 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 583.8 on 48 degrees of freedom
## Multiple R-squared: 0.1158, Adjusted R-squared: 0.09735
## F-statistic: 6.285 on 1 and 48 DF, p-value: 0.01562
slopeLE_In <-155.75
interceptLE_In <--6603.48
pLE_In <-0.01562
r2LE_In <-0.1158
ar2LE_In <-0.09735
frost_income_model <- lm(Income ~ Frost, data = state_x77_df)
summary(frost_income_model)
##
## Call:
## lm(formula = Income ~ Frost, data = state_x77_df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1192.12 -483.89 -22.45 383.72 1752.04
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4156.380 193.531 21.477 <2e-16 ***
## Frost 2.675 1.662 1.609 0.114
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 604.7 on 48 degrees of freedom
## Multiple R-squared: 0.0512, Adjusted R-squared: 0.03144
## F-statistic: 2.59 on 1 and 48 DF, p-value: 0.1141
slopeF_In <-2.675
interceptF_In <-4156.380
pF_In <-0.1141
r2F_In <-0.0512
ar2F_In <-0.03144
pIncome <- c(pLE_In, pF_In)
r2Income <- c(r2LE_In, r2F_In)
ar2Income <- c(ar2LE_In, ar2F_In)
slopeIncome <- c(slopeLE_In, slopeF_In)
interceptIncome <- c(interceptLE_In, interceptF_In)
income_stats <- cbind(slopeIncome, interceptIncome, pIncome, r2Income, ar2Income)
colnames(income_stats) <- c("Slope","Intercept", "P-Value", "R Squared Value", "Adjusted R Squared Value")
rownames(income_stats) <- c("Life Exp", "Frost")
income_stats
## Slope Intercept P-Value R Squared Value
## Life Exp 155.750 -6603.48 0.01562 0.1158
## Frost 2.675 4156.38 0.11410 0.0512
## Adjusted R Squared Value
## Life Exp 0.09735
## Frost 0.03144
Frost
life_exp_frost_model <- lm(Frost ~ `Life Exp`, data = state_x77_df)
summary(life_exp_frost_model)
##
## Call:
## lm(formula = Frost ~ `Life Exp`, data = state_x77_df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -132.077 -24.803 9.876 27.740 102.299
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -614.811 382.370 -1.608 0.114
## `Life Exp` 10.148 5.394 1.881 0.066 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 50.68 on 48 degrees of freedom
## Multiple R-squared: 0.06868, Adjusted R-squared: 0.04928
## F-statistic: 3.54 on 1 and 48 DF, p-value: 0.06599
slopeLE_F <-10.148
interceptLE_F <--614.811
pLE_F <-0.06599
r2LE_F <-0.06868
ar2LE_F <-0.04928
pFrost <- c(pLE_F)
r2Frost <- c(r2LE_F)
ar2Frost <- c(ar2LE_F)
slopeFrost <- c(slopeLE_F)
interceptFrost <- c(interceptLE_F)
frost_stats <- cbind(slopeFrost, interceptFrost, pFrost, r2Frost, ar2Frost)
colnames(frost_stats) <- c("Slope","Intercept", "P-Value", "R Squared Value", "Adjusted R Squared Value")
rownames(frost_stats) <- c("Life Exp")
frost_stats
## Slope Intercept P-Value R Squared Value Adjusted R Squared Value
## Life Exp 10.148 -614.811 0.06599 0.06868 0.04928
Scatterplots for data correlation testing
Murder
hs_grad_murder_df <- state_x77_df %>%
add_predictions(hs_grad_murder_model)
ggplotly(
ggplot(data = hs_grad_murder_df)+
geom_point(mapping = aes(x = `HS Grad`, y = Murder, group = state.abb))+
geom_line(
mapping = aes(x =`HS Grad`, y = pred),
color = "red"
)
)
illiteracy_murder_df <- state_x77_df %>%
add_predictions(illiteracy_murder_model)
ggplotly(
ggplot(data = illiteracy_murder_df)+
geom_point(mapping = aes(x = Illiteracy, y = Murder, group = state.abb))+
geom_line(
mapping = aes(x =Illiteracy, y = pred),
color = "red"
)
)
life_exp_murder_df <- state_x77_df %>%
add_predictions(life_exp_murder_model)
ggplotly(
ggplot(data = life_exp_murder_df)+
geom_point(mapping = aes(x = `Life Exp`, y = Murder, group = state.abb))+
geom_line(
mapping = aes(x = `Life Exp`, y = pred),
color = "red"
)
)
income_murder_df <- state_x77_df %>%
add_predictions(income_murder_model)
ggplotly(
ggplot(data = income_murder_df)+
geom_point(mapping = aes(x = Income, y = Murder, group = state.abb))+
geom_line(
mapping = aes(x = Income, y = pred),
color = "red"
)
)
frost_murder_df <- state_x77_df %>%
add_predictions(frost_murder_model)
ggplotly(
ggplot(data = frost_murder_df)+
geom_point(mapping = aes(x = Frost, y = Murder,group = state.abb))+
geom_line(
mapping = aes(x = Frost, y = pred),
color = "red"
)
)
Illiteracy
hs_grad_illiteracy_df <- state_x77_df %>%
add_predictions(hs_grad_illiteracy_model)
ggplotly(
ggplot(data = hs_grad_illiteracy_df)+
geom_point(mapping = aes(x = `HS Grad`, y = Illiteracy, group = state.abb))+
geom_line(
mapping = aes(x = `HS Grad`, y = pred),
color = "red"
)
)
life_exp_illiteracy_df <- state_x77_df %>%
add_predictions(life_exp_illiteracy_model)
ggplotly(
ggplot(data = life_exp_illiteracy_df)+
geom_point(mapping = aes(x = `Life Exp`, y = Illiteracy, group = state.abb))+
geom_line(
mapping = aes(x = `Life Exp`, y = pred),
color = "red"
)
)
income_illiteracy_df <- state_x77_df %>%
add_predictions(income_illiteracy_model)
ggplotly(
ggplot(data = income_illiteracy_df)+
geom_point(mapping = aes(x = Income, y = Illiteracy, group = state.abb))+
geom_line(
mapping = aes(x = Income, y = pred),
color = "red"
)
)
frost_illiteracy_df <- state_x77_df %>%
add_predictions(frost_illiteracy_model)
ggplotly(
ggplot(data = frost_illiteracy_df)+
geom_point(mapping = aes(x = Frost, y = Illiteracy, group = state.abb))+
geom_line(
mapping = aes(x = Frost, y = pred),
color = "red"
)
)
HS Grad
life_exp_hs_grad_df <- state_x77_df %>%
add_predictions(life_exp_hs_grad_model)
ggplotly(
ggplot(data = life_exp_hs_grad_df)+
geom_point(mapping = aes(x = `Life Exp`, y = `HS Grad`, group = state.abb))+
geom_line(
mapping = aes(x = `Life Exp`, y = pred),
color = "red"
)
)
income_hs_grad_df <- state_x77_df %>%
add_predictions(income_hs_grad_model)
ggplotly(
ggplot(data = income_hs_grad_df)+
geom_point(mapping = aes(x = Income, y = `HS Grad`, group = state.abb))+
geom_line(
mapping = aes(x = Income, y = pred),
color = "red"
)
)
frost_hs_grad_df <- state_x77_df %>%
add_predictions(frost_hs_grad_model)
ggplotly(
ggplot(data = frost_hs_grad_df)+
geom_point(mapping = aes(x = Frost, y = `HS Grad`, group = state.abb))+
geom_line(
mapping = aes(x = Frost, y = pred),
color = "red"
)
)
Income
frost_income_df <- state_x77_df %>%
add_predictions(frost_income_model)
ggplotly(
ggplot(data = frost_income_df)+
geom_point(mapping = aes(x = Frost, y = Income, group = state.abb))+
geom_line(
mapping = aes(x = Frost, y = pred),
color = "red"
)
)
life_exp_income_df <- state_x77_df %>%
add_predictions(life_exp_income_model)
ggplotly(
ggplot(data = life_exp_income_df)+
geom_point(mapping = aes(x = `Life Exp`, y = Income, group = state.abb))+
geom_line(
mapping = aes(x = `Life Exp`, y = pred),
color = "red"
)
)
Frost
life_exp_frost_df <- state_x77_df %>%
add_predictions(life_exp_frost_model)
ggplotly(
ggplot(data = life_exp_frost_df)+
geom_point(mapping = aes(x = `Life Exp`, y = Frost, group = state.abb))+
geom_line(
mapping = aes(x = `Life Exp`, y = pred),
color = "red"
)
)